﻿#ifndef NctiDCM3Variable_H
#define NctiDCM3Variable_H
#include "dcl_ncti_object.h"
#include "NctiDisplayGModelObject.h"
#include "NctiDCM3Def.h"
namespace NCTI
{
	class NctiDisplayDCM3Dimension;
	class NctiDCM3Equation;
	class DECL_NCTI_OBJECT NctiDCM3Variable : public NctiDisplayGModelObject
	{
		NCTI_DISPLAYOBJECT_FUNCTIONS(NctiDCM3Variable)
	public:
		virtual ~NctiDCM3Variable();
	public:
		virtual void Init();
		virtual EnumNctiResult UpdateDisplay();
	private:
		NCTI_READ_AND_WRITE_VERSION_FUN(1)
		double m_fvalue;
		const char* m_fname;
		Ncti_Address m_fnode;
		NctiDisplayDCM3Dimension* m_pDimension;
		NCTI_V_NODE m_fv_node;
		bool m_fvalue_set;
		std::set<NctiDCM3Equation*> m_owners;
		ncti_DCM3_g_node_status m_status;
	public:
		void InitVariable(const char* i_name, double i_val);
		void InitVariable(const char* i_name, Ncti_Address i_node, NctiDisplayDCM3Dimension* i_pDim);
	public:
		virtual std::string describe() const;
	public:
		void AddOwner(NctiDCM3Equation* i_pEquation);
		void RemoveFromOwner();

		void set_status(ncti_DCM3_g_node_status i_status) { m_status = i_status; }
		ncti_DCM3_g_node_status status() const { return m_status; }
		bool has_value() const { return m_fvalue_set; }
		double value() const { return m_fvalue; }
		void set_value(double i_val);
		NCTI_V_NODE vnode() { return m_fv_node; }
		void set_vnode(NCTI_V_NODE i_vn);
		Ncti_Address dim_node() const { return m_fnode; }
		NctiDisplayDCM3Dimension* dimension() const { return m_pDimension; }
		const char* name() { return m_fname; }
	};
}
#endif